<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title> 密码生成 </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="author" content="" />
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<link rel="stylesheet" href="../public/css/widgets.css" />
	<script type="text/javascript" src="../public/js/jquery.1.7.js"></script>
	<script type="text/javascript" src="genpwd.js"></script>
	<script type="text/javascript">
		$(function(){
			$('input[type="submit"]').click(function(){
				if($('input:checked').size() < 1){
					alert('至少得选字母吧。');
					return false;
				}
				var b = new genpwd({
					withdigits:$('#digits').attr('checked') === 'checked',
					withletters:$('#letters').attr('checked') === 'checked',
					withspecialchar:$('#specialchar').attr('checked') === 'checked',
					capital:$('#capital').attr('checked') === 'checked'
				});
				$('#output').val(b.gen($('#pwdlength').val()));
			});
		});
	</script>
	<style type="text/css">
	.section{margin-bottom:10px;}
	.center{text-align:center;}
	.wrap{width:500px;margin:15% auto;}
	.output{font-size:1.5em;height:1em;text-align:center;padding:15px 20px;color:#aaa;border:1px solid #eee;}
	.copyright{font-size:11px;line-height:2em;}
	</style>
</head>

<body>
	<div class="wrap">
		<input type="text" name="output" id="output" size="40" class="section output" />
		<div class="section options">
			<table width="100%" cellpadding="4" cellspacing="4">
				<tr>
					<td>
						<input type="checkbox" id="digits" name="digits">
						<label for="digits">包含数字</label>
					</td>
					<td>
						<input type="checkbox" id="letters" name="letters">
						<label for="letters">包含字母</label>
					</td>
				</tr>
				<tr>
					<td>
						<input type="checkbox" id="capital" name="capital">
						<label for="capital">包含大小写</label>
					</td>
					<td>
						<input type="checkbox" id="specialchar" name="specialchar">
						<label for="specialchar">包含特殊字符</label>
					</td>
				</tr>
				<tr>
					<td>
						<label for="pwdlength">密码长度</label>
						<select name="pwdlength" id="pwdlength">
							<option value="6">6</option>
							<option value="8">8</option>
							<option value="12">12</option>
							<option value="16">16</option>
							<option value="20">20</option>
							<option value="32">32</option>
						</select>
					</td>
				</tr>
			</table>
		</div>
		<div class="section submit center">
			<input type="submit" class="button button-blue" value="生成密码">
			<input type="button" class="button button-green" value="复制密码" onclick="copyToClipboard($('#output').val());alert($('#output').val() + '已复制到剪贴板，Ctrl+V粘贴');">
		</div>
		<div class="section copyright center">
			2012 &copy; codz by <a href="http://www.leosio.com" title="">Leo</a>
		</div>
	</div>
	<script type="text/javascript">
	function copyToClipboard(txt){
		if(window.clipboardData){
			window.clipboardData.clearData();
			window.clipboardData.setData("Text", txt);
		}else if(navigator.userAgent.indexOf("Opera") != -1){
			//暂时无方法:-(
		}else if (window.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch (e){
				alert("请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
				return false;
			}
			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
			if (!clip)
				return;
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
			if (!trans)
				return;
			trans.addDataFlavor('text/unicode');
			var str = new Object();
			var len = new Object();
			var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
			var copytext = txt;
			str.data = copytext;
			trans.setTransferData("text/unicode",str,copytext.length*2);
			var clipid = Components.interfaces.nsIClipboard;
			if (!clip)
				return false;
			clip.setData(trans,null,clipid.kGlobalClipboard);
		}
	}
	</script>
	<script type="text/javascript" src="http://js.tongji.linezing.com/641242/tongji.js"></script>
	<noscript><a href="http://www.linezing.com"><img src="http://img.tongji.linezing.com/641242/tongji.gif"/></a></noscript>
</body>
</html>
